Back to course home
0% completed
Vote For New Content
Oracle Hard
Integer to English Words (hard)
Solution: Integer to English Words
Trapping Rain Water (hard)
Solution: Trapping Rain Water
First Missing Positive (hard)
Solution: First Missing Positive
Merge K Sorted Lists (hard)
Solution: Merge K Sorted Lists
Max Points on a Line (hard)
Solution: Max Points on a Line
Sudoku Solver (hard)
Solution: Sudoku Solver
Longest Valid Parentheses (hard)
Solution: Longest Valid Parentheses
Remove Nth Node From End of List (Medium)
Solution: Remove Nth Node From End of List
Median of Two Sorted Arrays (hard)
Solution: Median of Two Sorted Arrays
Constrained Subsequence Sum (hard)
Solution: Constrained Subsequence Sum
Group Anagrams (Medium)
Problem Statement
Given a list of strings, the task is to group the anagrams together.
An anagram is a word or phrase formed by rearranging the letters of another, such as "cinema", formed from "iceman"
You can return the answer in any order.
Examples
Example 1:
- Input:
["dog", "god", "hello"] - Output:
[["dog", "god"], ["hello"]] - Justification: "dog" and "god" are anagrams, so they are grouped together. "hello" does not have any anagrams in the list, so it is in its own group.
Example 2:
- Input:
["listen", "silent", "enlist"] - Output:
[["listen", "silent", "enlist"]] - Justification: All three words are anagrams of each other, so they are grouped together.
Example 3:
- Input:
["abc", "cab", "bca", "xyz", "zxy"] - Output:
[["abc", "cab", "bca"], ["xyz", "zxy"]] - Justification: "abc", "cab", and "bca" are anagrams, as are "xyz" and "zxy".
Constraints:
- 1 <= strs.length <= 104
0 <= strs[i].length <= 100strs[i]consists of lowercase English letters.
Try it yourself
Try solving this question here:
Java
. . . .
Solution: Sort Colors
Solution: Group Anagrams
Mark as Completed
On this page
Problem Statement
Examples
Try it yourself